<?php

/**
* @current fashionweek.php
* @author   LiuYang <liu_yang@haibao.com>
* @date 2016年9月2日 下午6:04:13
*/
namespace haibao\cms\business;

use  haibao\cms\data\FashionWeek as FashionWeekData; 

class FashionWeek extends \haibao\cms\business\Base{
    public static function getFashionList($filter,$isGetOne = true){
        $data = new FashionWeekData();
        if($isGetOne){
            return $data->getOne($filter);
        }else{
            return $data->getAll($filter);   
        }
    }
    
    public static function delFashionById($id, $arrSet){
        $data = new FashionWeekData();
        return $data->updateById($id, $arrSet);
    }
    
    public static function addfashion($model){
        self::checkOperation(self::FUNC_CODE_FASHION_WEEK_ADD);
        self::checkFashionModelData($model);
        $data = new FashionWeekData();
        $data->addFashionData($model);
        self::saveOperateHistory(self::FUNC_CODE_FASHION_WEEK_ADD, $model->toArray(true,true));
    }
    
    public static function editfashion($model){
        self::checkOperation(self::FUNC_CODE_FASHION_WEEK_EDIT);
        self::checkFashionModelData($model);
        $data = new FashionWeekData();
        $data->editFashionData($model);
        self::saveOperateHistory(self::FUNC_CODE_FASHION_WEEK_EDIT, $model->toArray(true,true));
    }
    private static function checkFashionModelData($model){
        if(!$model){
            throw new BusinessException('error');
        }
        if(!$model->EventId){
            throw new BusinessException('相关事件不可以为空！');
        }
        if(!$model->ImageId){
            throw new BusinessException('导读图不可以为空');
        }
    }
    public static function getfashionListById($fashionId){
        $data = new FashionWeekData();
        return $data->getOneById($fashionId);
    }
    
    public static function getFshionWeekList($eventId,$page = 0){
        $data = new FashionWeekData();
        return $data->getFshionWeekList($eventId,$page);
    }
    
    public static function getArticlePro($articleIds){
        $data = new FashionWeekData();
        return $data->getArticlePro($articleIds);
    }
    
    public static function getImageCollectivePro($imageCollectiveIds){
        $data = new FashionWeekData();
        return $data->getImageCollectivePro($imageCollectiveIds);
    }
    
    public static function updateClickNumById($fashionId){
        $data = new FashionWeekData();
        $data->updateClickNumById($fashionId);
    }
}
